
<template>
<div>
        <BHeader></BHeader>
<div class="listcontent">
			<div class="cont_title">
				<span>全部订单</span>
			</div>
			<div class="cont_op">
				<div>订单信息</div>
				<div>订单总金额</div>
				<div>收货地址</div>
				<div>订单状态</div>
				<div>操作</div>
			</div>
			<div class="pro_box" v-if="orderlist.length">
				<div class="orders" v-for="(order, index) in orderlist" :key="index">
					<ul class="item_content">
						<li class="td-item">
                            <div class="td-item-num">{{order.id}}</div>
							
						</li>
						<li class="td td-sum"><strong><p>{{order.payPrice}}</p></strong></li>
				        <li class="td "><p>{{order.address}}</p></li>
						<li class="td ">{{order.status}}</li>
						<li class="td td-op" v-show="order.status =='已支付'"><a>取消订单</a></li>
						<li class="td td-op" v-show="order.status =='未支付'"><a>去付款</a></li>
						
					</ul>
				</div>
			</div>
      <div class="pro_box" v-else>没有订单数据</div>
</div>
</div>
</template>
<style scoped>
.listcontent>.cont_title{
	margin: 10px auto;
	width: 80%;
	height: 35px;
	border-bottom: 2px solid #e6e6e6;
}
.cont_title>span{
	display: inline-block;
	font-weight: 700;
    font-size: 17px;
    height: 100%;
    width: 100px;
    text-align: center;
    line-height: 25px;
    cursor: pointer;
    color: #f40;
    border-bottom: 2px solid #f40;
}
.listcontent>.cont_op{
	width: 80%;
  margin: 0 auto;
	height: 40px;
	display: flex;
	justify-content: space-around;
}
.cont_op>div{
	line-height: 40px;
}
.cont_op>div:nth-child(1){
	width: 120px;
}
.listcontent>.pro_box{
  margin: 0 auto;
	width: 80%;
}
.pro_box>.orders{
	background: #fcfcfc;
	width: 100%;
	height: auto;
	border: 1px solid #CCCCCC;
}
.orders>.item_content{
	padding: 15px;
  list-style: none;
	display: flex;
	justify-content: space-around;
}

.item_content>.td-item{ 
	width: 120px 
    
}
.td
{
	height: auto;
	padding-top: 20px;
	width: 80px;
}
.td-item>div{
     display: block;
}
.td-item>.td-item-num{
	width: 100px;
    text-align: center;
    line-height: 20px !important;
  
}
.td-item>.td-item-pic>img{
	width: 80px !important;
	height: 80px !important;
}

.item_content>.td-sum{
	color: #f40;
}

.td-op a{
	color: black;
}
.td-op a:hover{
	cursor: pointer;
	color: #f40;
}

</style>
<script>
import BHeader from '../../components/BHeader.vue'
import {getOrders} from '../../api/order/order'
export default {
    name:'Orderlist',
    components:{
        BHeader
    },
  data() {
    return {
          orderlist:[]
    };
  },
  methods: {
	  getOrderList(){
         getOrders().then((res)=>{
			 if(res.flag){
				 this.orderlist=res.data
			 }
		 })
	  }
  },
  created(){
	  if(this.$store.getters.token==null){
		  this.$router.push("/")
	  }
	  this.getOrderList();
  }
};
</script>